package fr.afcepf.ticketing.service;

import java.util.List;
import javax.ejb.EJB;
import javax.ejb.Stateless;

import fr.afcepf.ticketing.dao.TicketDao;
import fr.afcepf.ticketing.domain.Ticket;

@Stateless
public class TicketServicesBean implements TicketServices {
	
	@EJB
	private TicketDao ejbTicketDao;


	public List<Ticket> getTicketByType(long id){
		return (List<Ticket>) ejbTicketDao.allTickets(id);
		
	}
	
	@Override
	public Ticket getTicketById(long id) {
		return ejbTicketDao.getEntityByPk(id);
	}
	

	@Override
	public void updateTicket(Ticket ticket) {
		ejbTicketDao.updateEntity(ticket);

	}

	@Override
	public void deleteTicket(long id) {
		ejbTicketDao.deleteEntityFromPk(id);

	}

	@Override
	public long insertNewTicket(Ticket ticket) {
		ejbTicketDao.createEntity(ticket);
		return ticket.getId();
	}

}
